package com.yzh.exception4;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * @author 于振晗
 * @title: Test
 * @description: TODO
 * @date 2020年08月29日
 * @path com.yzh.exception4
 */
public class Test {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入数字：");
        try {

            int num = input.nextInt();
            if (num < 1 || num > 4) {
                throw new Exception("必须在1-4之间！");
            }
            System.out.println(1);
            return;
        } catch (InputMismatchException e) {
            System.out.println("InputMismatchException");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }finally{
            System.out.println(2);
        }
        System.out.println(3);
    }
}
